// pages/templates/templates.js
var util = require("../../utils/util.js");
var baseImgUrl = util.baseImgUrl;
Page({

  /**
   * 页面的初始数据
   */
  data: {
      tab1:"主页",
      tab2:"咨询",
      tab3:"读书",
      tab4:"购物",
      scanUrl: baseImgUrl + "scan.png",//浏览量图片
    certifyUrl: "../images/certify.png",//已认证图片路径
    uncertifyUrl: "../images/uncertify.png",//未认证图片路径
    hotUrl: "../images/hot.png",//人气图片路径
    positionUrl: "../images/position.png",//距离图片路径
    distance: 5,//测试数据  距离
    followedUrl: "../images/followed.png",//已关注的图片路径
    unfollowUrl: "../images/unfollowed.png",//未关注的图片路径
    scanUrl: baseImgUrl + "scan.png",//浏览量图片
    showfujin: false,//是否显示附近选择面板
    shouClass: false,//是否显示选择类别
    activeClass: 0,//选中的类别
    goodslist: [{
      id: 0,
      goodsUrl: baseImgUrl + "goods1.png",
      goodsname: "女友礼物精选集",
      content: "商品的介绍内容品的介绍内容商品的介绍内容商品的介绍内容s",
      biaoqian: ["今日秒杀", "HOT热卖", "特卖"],
      price: 45,
      scanNum: 1234,
      scanUrl: baseImgUrl + "scan.png",
    }, {
      id: 1,
      goodsUrl: baseImgUrl + "goods2.png",
      goodsname: "女友礼物精选集",
      content: "商品的介绍内容",
      biaoqian: ["今日秒杀", "HOT热卖", "特卖"],
      price: 95,
      scanNum: 1200,
      scanUrl: baseImgUrl + "scan.png",
    }, {
      id: 2,
      goodsUrl: baseImgUrl + "goods2.png",
      goodsname: "女友礼物精选集",
      content: "商品的介绍内容商",
      biaoqian: ["今日秒杀", "HOT热卖", "特卖"],
      price: 125,
      scanNum: 1000,
      scanUrl: baseImgUrl + "scan.png",
    }, {
      id: 3,
      goodsUrl: baseImgUrl + "goods2.png",
      goodsname: "女友礼物精选集",
      content: "商品的介绍内容商品的介绍内容商品的介绍内容商品的介绍内容",
      biaoqian: ["今日秒杀", "HOT热卖", "特卖"],
      price: 125,
      scanNum: 1000,
      scanUrl: baseImgUrl + "scan.png",
    }, {
      id: 4,
      goodsUrl: baseImgUrl + "goods2.png",
      goodsname: "女友礼物精选集",
      content: "商品的介绍内容商",
      biaoqian: ["今日秒杀", "HOT热卖", "特卖"],
      price: 125,
      scanNum: 1000,
      scanUrl: baseImgUrl + "scan.png",
    }, {
      id: 5,
      goodsUrl: baseImgUrl + "goods2.png",
      goodsname: "女友礼物精选集",
      content: "商品的介绍内容商品的介绍内容商品的介绍内容商品的介绍内容",
      biaoqian: ["今日秒杀", "HOT热卖", "特卖"],
      price: 125,
      scanNum: 1000,
      scanUrl: baseImgUrl + "scan.png",
    }],
      
  },

  tabbarinit:function (){
    return [
      {
        "current": 0,
        "pagePath": "/pages/index/index",
        "iconPath": "/imgs/home.png",
        "selectedIconPath": "/imgs/home_on.png",
        "text":this.data.tab1
      },
      {
        "current": 0,
        "pagePath": "/pages/news/news",
        "iconPath": "/imgs/message.png",
        "selectedIconPath": "/imgs/message_on.png",
        "text": this.data.tab2

      },
      {
        "current": 0,
        "pagePath": "/pages/category/category",
        "iconPath": "/imgs/category.png",
        "selectedIconPath": "/imgs/category_on.png",
        "text":this.data.tab3
      },
      {
        "current": 0,
        "pagePath": "/pages/buy/buy",
        "iconPath": "/imgs/buy.png",
        "selectedIconPath": "/imgs/buy_on.png",
        "text":this.data.tab4
      }
    ]

  },



  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})
//初始化数据
function tabbarinit() {
  return [
    {
      "current": 0,
      "pagePath": "/pages/index/index",
      "iconPath": "/imgs/home.png",
      "selectedIconPath": "/imgs/home_on.png",
      "text": "主页"
    },
    {
      "current": 0,
      "pagePath": "/pages/news/news",
      "iconPath": "/imgs/message.png",
      "selectedIconPath": "/imgs/message_on.png",
      "text": "资讯"

    },
    {
      "current": 0,
      "pagePath": "/pages/category/category",
      "iconPath": "/imgs/category.png",
      "selectedIconPath": "/imgs/category_on.png",
      "text": "分类"
    },
    {
      "current": 0,
      "pagePath": "/pages/buy/buy",
      "iconPath": "/imgs/buy.png",
      "selectedIconPath": "/imgs/buy_on.png",
      "text": "购物"
    }
  ]

}
//tabbar 主入口
function tabbarmain(bindName = "tabdata", id, target) {
  var that = target;
  var bindData = {};
  var otabbar = tabbarinit();
  otabbar[id]['iconPath'] = otabbar[id]['selectedIconPath']//换当前的icon
  otabbar[id]['current'] = 1;
  bindData[bindName] = otabbar
  that.setData({ bindData });
}

module.exports = {
  tabbar: tabbarmain
}